<script type="text/javascript" src="${ctx}/static/js/common.js"></script>
<link rel="stylesheet" href="${ctx}/static/js/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="${ctx}/static/js/zTree_v3/js/jquery.ztree.all-3.5.js"></script>
<span id="${uuid}"></span>
<ul data-id="index_tree" class="ztree"></ul>	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="hidden" data-id="member_role_userId" value="${userId}">
<script type="text/javascript">
    (function($){
        var setting = {
            check: {
                enable: true,
                chkboxType: { "Y": "s", "N": "s" }
            },
            data: {
                simpleData: {
                    enable: false
                }
            }
        };
        var treeId = $.utils.createUUID(6);
        var uuid = "${uuid}";
        var page = new $.PageDomFactory(uuid);
        var tree =  page.getJqDom("index_tree").attr("id", treeId);
        $.getJSON("${pageContext.request.contextPath}/app/api/sysMember/showRes?id=${userId}",function(json){
            $.fn.zTree.init(tree, setting, json);
        });

        $[uuid] = {
            pageContext:page,
            treeId:treeId
        }
    })(jQuery);
	function resource_save(win){
        win.wait("start","保存中,请稍候.");
		var treeObj = $.fn.zTree.getZTreeObj($["${uuid}"].treeId);
		var nodes = treeObj.getCheckedNodes(true);
		var ids= nodes.map(function(item){return item.id});
		$.post("${pageContext.request.contextPath}/app/api/sysMember/saveUserResource", $.utils.buildJson({'ids':ids,userId: $["${uuid}"].pageContext.getJqDom("member_role_userId").val()}),function(json){
            win.wait("end");
			$.messager.alert('信息','保存成功!','info');
            win.close();
		},'json');
	}
</script>
